<div class="user">
  <nz-collapseset>
    <nz-collapse [nzTitle]="panels.name" [nzActive]="panels.active" [nzDisabled]="panels.disabled">
      <form nz-form [nzLayout]="'inline'">
        <div nz-row>

          <div nz-form-item nz-col [nzSpan]="4">
            <div nz-form-label nz-col [nzSm]="9" [nzXs]="6">
              <label>用户姓名</label>
            </div>
            <div nz-form-control nz-col [nzSm]="12" [nzXs]="12">
              <nz-input [(ngModel)]="userBean.userName" name="userName">
              </nz-input>
            </div>
          </div>
          <div nz-form-label nz-col [nzSpan]="2">
            <label>单位名称</label>
          </div>
          <div nz-form-control nz-col [nzSpan]="4">
            <nz-input [(ngModel)]="userBean.partyName" name="partyName">
            </nz-input>
          </div>
          <button style="margin-left: 30px;" nz-button [nzSize]="'middle'" [nzType]="'primary'" (click)="query()">查询</button>
        </div>
      </form>
    </nz-collapse>
  </nz-collapseset>
  <ul nz-menu [nzMode]="'horizontal'">
    <li permission="SID00001" nz-menu-item (click)="add(title, content, footer)">
      <i class="anticon anticon-plus"></i>添加</li>
    <li permission="SID00002" nz-menu-item (click)="update(title, content, footer)">
      <i class="anticon anticon-copy"></i>修改</li>
    <li permission="SID00003" nz-menu-item (click)="delete()">
      <i class="anticon anticon-delete"></i>删除</li>
    <li permission="SID00001" nz-menu-item (click)="showUpload(titleUpload, contentUpload, footerUpload)">
      <i class="anticon anticon-copy"></i>导入</li>

    <li *ngIf="showWN==false" permission="SID00001" nz-menu-item (click)="download('/information/user.xlsx','用户导入模板.xlsx')">

      <i class="anticon anticon-copy"></i>下载用户导入模板</li>

    <li *ngIf="showWN==true" permission="SID00001" nz-menu-item (click)="download('/information/regulate_user.xlsx','用户导入模板.xlsx')">

      <i class="anticon anticon-copy"></i>下载用户导入模板</li>

    <li nz-menu-item (click)="updateUserState()">
      <i class="anticon anticon-copy"></i>停用或启用</li>
    <li nz-menu-item (click)="addMeatasisDialog(titleP, contentP, footerP)">
      <i class="anticon anticon-copy"></i>转移用户</li>
  </ul>
  <p class="anticon anticon-exclamation-circle-o" style="color:red;font-weight:bolder;margin-left:20px;"></p><span
    style="color:red;font-weight:bolder;">
    重要提示：特种设备作业人员的用户账号停用/转移前，请确保该用户名下设备作业权限已更改！</span>
  <nz-table #nzTable  [nzDataSource]="list" nzSize="middle" [nzBordered]="true" [nzIsPagination]="false" (nzDataChange)="displayDataChange($event)">
    <thead nz-thead>
      <tr>
        <th  nz-th [nzCheckbox]="true">
          <label nz-checkbox [(ngModel)]="allChecked" [nzIndeterminate]="indeterminate" (ngModelChange)="checkAll($event)">
          </label>
        </th>
        <th nz-th   style="text-align: center;">
          <span>单位名称</span>
        </th>
        <th nz-th   style="text-align: center;">
          <span>姓名</span>
        </th>
        <th nz-th   style="text-align: center;" >
          <span>角色名称</span>
        </th>
        <th nz-th style="text-align: center;">
          <span>账号</span>
        </th>
        <th *ngIf="isTrue" nz-th style="text-align: center;">
          <span>密码</span>
        </th>
        <th *ngIf="showWN" nz-th style="text-align: center;  ">
          <span>工号</span>
        </th>
        <th nz-th style="text-align: center;  ">
          <span>身份证号</span>
        </th>
        <th nz-th style="text-align: center;  ">
          <span>用户持证类型</span>
        </th>
        <th nz-th style="text-align: center;  ">
          <span>账号状态</span>
        </th>
      </tr>
    </thead>
    <tbody nz-tbody>
      <tr nz-tbody-tr *ngFor="let data of list">
        <td nz-td [nzCheckbox]="true">
          <label nz-checkbox [nzDisabled]="data.disabled" [(ngModel)]="data.checked" (ngModelChange)="refreshStatus($event)">
          </label>
        </td>
        <td nz-td >  <span>{{data.partyName}}</span> </td>
        <td nz-td >  <span>{{data.userName}}</span> </td>
        <td nz-td > {{data.roleName}}</td>
        <td nz-td  >{{data.userCode}}</td>
        <td nz-td *ngIf="isTrue" >{{data.password}}</td>
        <td *ngIf="showWN" nz-td >{{data.workNumber}}</td>
        <td nz-td >{{data.cardNumber}}</td>
        <td nz-td >{{data.cardType}}</td>
        <td nz-td >{{data.userState | constantTransfer:userState}}</td>
      </tr>
    </tbody>
  </nz-table>

  <nz-pagination [nzPageIndex]="userBean.currentPage" nzShowTotal [nzTotal]="total" nzShowSizeChanger
    (nzPageSizeChange)="nzPageSizeChange($event)" (nzPageIndexChange)="nzPageIndexChange($event)"
    (nzPageIndexClickChange)="nzPageIndexClickChange($event)" [nzPageSize]="userBean.pageSize"></nz-pagination>

  <!--添加页面 -->
  <ng-template #title>
    <span>{{modelTitle}}</span>
  </ng-template>
  <ng-template #content>
    <user-add-page *ngIf="modal==0" (outPut)="addOutPut($event)"></user-add-page>
    <user-modify-page *ngIf="modal==1" [inValue]="updateData" (outPut)="addOutPut($event)"></user-modify-page>
  </ng-template>
  <ng-template #footer>
    <div>
    </div>
  </ng-template>

  <ng-template #titleP>
    <span>用户转移</span>
  </ng-template>
  <ng-template #contentP>
    <form nz-form>
      <div nz-form-item nz-row>
        <div nz-form-label nz-col [nzSpan]="9">
          <label for="toParty">转移给</label>
        </div>
        <div nz-form-control nz-col [nzSpan]="8">
          <nz-select nzAllowClear name="toParty" [nzPlaceHolder]="'请选择单位'" [nzShowSearch]="true" [nzSize]="'large'"
            [(ngModel)]="toParty">
            <nz-option *ngFor="let item of partySeleList" [nzLabel]="item.partyName" [nzValue]="item.id"></nz-option>
          </nz-select>

        </div>
      </div>
      <div nz-form-item nz-row style="margin-bottom:8px;">
        <div nz-form-control nz-col [nzSpan]="14" [nzOffset]="10">
          <button nz-button (click)="addMeatasis()" [nzSize]="'large'" [nzType]="'primary'">确定</button>
        </div>
      </div>

    </form>

  </ng-template>
  <ng-template #footerP>
    <div>
    </div>
  </ng-template>

  <ng-template #titleUpload>
    <span>导入</span>
  </ng-template>
  <ng-template #contentUpload>
    <div>
      导入用户信息：
      <nz-upload nzAction="{{config.IP+config.API.uploadUser}}" [nzData]="upLoadParam" (nzChange)="uploadChage($event)"
        [nzShowUploadList]="false">
        <button nz-button>
          <i class="anticon anticon-upload"></i>
          <span>导入</span>
        </button>
      </nz-upload>
    </div>
  </ng-template>
  <ng-template #footerUpload>
    <div>
    </div>
  </ng-template>
</div>
